package com.nguyen.letcook;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class SplashScreen extends Activity implements OnClickListener{
	private static final int SPLASH_TIME = 3000;
	int time = 0;
	Thread mThread;
	ImageView imgSplash;
	
	@Override
	public void onCreate(Bundle bundle){
		super.onCreate(bundle);
		setContentView(R.layout.splash_screen);
		imgSplash = (ImageView) findViewById(R.id.imgSplash);
		imgSplash.setOnClickListener(this);
		mThread = new Thread(new Runnable() {
			
			@Override
			public void run() {
				try {
					while(true){
						Thread.sleep(500);
						time+= 500;
						if(time >= SPLASH_TIME)
							break; 
					}
					
					Intent intent = new Intent(SplashScreen.this, MainTabHost.class);
					intent.putExtra("demo", "hello");
					SplashScreen.this.startActivity(intent);
					SplashScreen.this.finish();
				} catch (InterruptedException e) {
					
					e.printStackTrace();
				}
				
			}
		});
		mThread.start();
	}
	
	@Override
	public void onClick(View v){ 
		if(v == imgSplash)
			time = SPLASH_TIME;
	}
}
